import {defineStore} from 'pinia'
import {getUserInfo} from '@/service/userInfo'
import { to } from 'await-to-js'
import {ElMessage} from 'element-plus'
import {userInfoData} from '@/models/home/main'
export const useMainStore = defineStore('main', {
    state: () => {
        return {
            userInfo: {}
        }
    },
    getters: {
        // getIsList(): boolean {
        //     return this.isList;
        // }
    },
    actions: {
        async getUserInfo() {
            const [err, res] = await to(getUserInfo())
            if (err || (res && !res?.success)) {
              ElMessage.error('用户信息获取失败' + res?.message );
              return;
            }
            this.userInfo = res?.result || {}
        }
    }
})